* Presidential Hegemony and Democratic Backsliding in Latin America
*   Aníbal Pérez-Liñán, University of Notre Dame, USA
*   Nicolás Schmidt, University of the Republic, Uruguay
*   Daniela Vairo, University of the Republic, Uruguay
* Replication file, December 31 2018

use "Hegemony.dta", clear
xtset cowcode year

* Index 1
gen       hegemony1 = (c_pres+c_coal+j_pres+j_party)/4
label var hegemony1 "Hegemony (unweigthed)"

* Index 2
factor c_pres c_coal j_pres j_party, factors(1)
predict   hegemony2
label var hegemony2 "Hegemony (weigthed)"

* h is placeholder for specific index
gen       h = .
label var h "Executive Hegemony"

format %9.2f hegemony1 hegemony2 h

*Instruments
egen effectivem = mean(effective) if break !=.
egen polity2m = mean(polity2)     if break !=.
gen lewbel = (effective-effectivem)*(polity2-polity2m)
label var lewbel    "Lewbel instrument"

* Controls

corr hegemony2 hegemony1
sum  hegemony1 hegemony2
sum  hegemony1 hegemony2 if break != .

* Figure 1
gen       break100 = 100 if break == 1
label var break100 "Episodes of Breakdown"
label var year     "Year"
gen       hegemony = hegemony1 if break != .
label var hegemony "Hegemony (unweigthed)"

twoway (line hegemony year, msymbol(none) lcolor(black) cmissing(no))  ///
       (dropline break100 year, msymbol(none) lcolor(gs11)) ///
       if year > 1924 & year <2015, xscale(range(1925(15)2020)) xlabel(1925(15)2020) xtitle(,size(vsmall)) ylabel(, angle(0))  ///
	   by(ccode, cols(3) caption() note("(Gaps in the series reflect periods of authoritarian rule)", size(vsmall) position(6) ring(6) justification(center) )) ///
	   subtitle(,bcolor(none)) legend(size(vsmall) region(lp(blank))) ///
	   xsize(12) ysize(12)
	   
* Table 2 - Main Models
replace h = hegemony1
xtprobit break c.h
  estimates store M21
  margins, at(h=(20(10)70)) 
  marginsplot, xline(50) recast(line) recastci(rarea) ytitle("Prob. Breakdown") title("2.1 No controls, Unweighted", si(large)) saving(Fig_21, replace)
replace h = hegemony2
xtprobit break c.h
  estimates store M22
  margins, at(h=(-1(.25)1)) 
  marginsplot, xline(0) recast(line) recastci(rarea) ytitle("Prob. Breakdown") title("2.2 No controls, Weighted", si(large)) saving(Fig_22, replace)
replace h = hegemony1
xtprobit break c.h legpower enph region demonst pgdp g_1 polity2
  estimates store M23
  margins, at(h=(20(10)70)) 
  marginsplot, xline(50) recast(line) recastci(rarea) ytitle("Prob. Breakdown") title("2.3 Controls, Unweighted", si(large)) saving(Fig_23, replace)
replace h = hegemony2
xtprobit break c.h legpower enph region demonst pgdp g_1 polity2
  estimates store M24
  margins, at(h=(-1(.25)1)) 
  marginsplot, xline(0) recast(line) recastci(rarea) ytitle("Prob. Breakdown") title("2.4 Controls, Weighted", si(large)) saving(Fig_24, replace)
 
   *Figure 2
  graph combine Fig_21.gph Fig_22.gph Fig_23.gph Fig_24.gph   ///
      , ycommon rows(2) saving(Figure_2, replace)
 
  *Table 2
  esttab  M21 M22 M23 M24 /// 
      using "Table_2.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
	  stats ( N_g      N   sigma_u            ll, fmt(%9.0g %9.0g %9.3f %9.1f) ///
	  labels("Countries" "N" "Frailty variance" "Log-likelihood")) ///
	  starlevels(* 0.1 ** 0.05) replace nobase noomit label nodepvars ///
	  title("Table 2. Models of Democratic Breakdown, 1925-2016") ///
	  mtitles("No controls, Unweighted" "No controls, Weighted" "Controls, Unweighted" "Controls, Weighted") ///
	  order(h legpower enph region demonst pgdp g_1 polity2) 

  	  
	  
* Table 3 - Non-Linear
replace h = hegemony1
xtprobit break c.h c.h#c.h
  estimates store M31
  margins, dydx(h) // Marginal effect is significant at .05 level
  margins, at(h=(20(10)70)) 
  marginsplot, xline(50) recast(line) recastci(rarea) ytitle("Prob. Breakdown") title("3.1 No controls, Unweighted", si(large)) saving(Fig_31, replace) noci
replace h = hegemony2
xtprobit break c.h c.h#c.h
  estimates store M32
  margins, at(h=(-1(.25)1)) 
  marginsplot, xline(0) recast(line) recastci(rarea) ytitle("Prob. Breakdown") title("3.2 No controls, Weighted", si(large)) saving(Fig_32, replace) noci
replace h = hegemony1
xtprobit break c.h c.h#c.h legpower enph region demonst pgdp g_1 polity2
  estimates store M33
  margins, dydx(h)
  margins, at(h=(20(10)70)) 
  marginsplot, xline(50) recast(line) recastci(rarea) ytitle("Prob. Breakdown") title("3.3 Controls, Unweighted", si(large)) saving(Fig_33, replace) noci
replace h = hegemony2
xtprobit break c.h c.h#c.h legpower enph region demonst pgdp g_1 polity2
  estimates store M34
  margins, at(h=(-1(.25)1)) 
  marginsplot, xline(0) recast(line) recastci(rarea) ytitle("Prob. Breakdown") title("3.4 Controls, Weighted", si(large)) saving(Fig_34, replace) noci yscale(range(0 .1))

  *Figure 3
  graph combine Fig_31.gph Fig_32.gph Fig_33.gph Fig_34.gph   ///
      , ycommon rows(2) saving(Figure_3, replace)

  *Table 3
  esttab  M31 M32 M33 M34 /// 
      using "Table_3.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
	  stats ( N_g      N   sigma_u            ll, fmt(%9.0g %9.0g %9.3f %9.1f) ///
	  labels("Countries" "N" "Frailty variance" "Log-likelihood")) ///
	  starlevels(* 0.1 ** 0.05) replace nobase noomit label nodepvars ///
	  title("Table 3. Models with Quadratic Effects") ///
	  mtitles("No controls, Unweighted" "No controls, Weighted" "Controls, Unweighted" "Controls, Weighted") ///
	  order(h h#h legpower enph region demonst pgdp g_1 polity2) 
	  
	
* Table 4 _Endogeneity
replace h = hegemony1
ivprobit break        legpower enph region demonst pgdp g_1 polity2 (h = c.effective c.lewbel), first 
  estimates store M41
  margins, at(h=(20(10)70)) pr(p)
  marginsplot, xline(50) recast(line) recastci(rarea) ytitle("IV Probit Estimate") title("4.1 All breakdowns, Unweighted", si(large)) saving(Fig_41, replace) noci  	   
replace h = hegemony1
ivprobit coup         legpower enph region demonst pgdp g_1 polity2 (h = c.effective c.lewbel), first 
  estimates store M42
  margins, at(h=(20(10)70)) pr(p)
  marginsplot, xline(50) recast(line) recastci(rarea) ytitle("IV Probit Estimate") title("4.3 Coups, Unweighted", si(large)) saving(Fig_43, replace) noci	   
replace h = hegemony1
ivprobit takeover legpower enph region demonst pgdp g_1 polity2 (h = c.effective c.lewbel), first 
  estimates store M43
  margins, at(h=(20(10)70)) pr(p)
  marginsplot, xline(50) recast(line) recastci(rarea) ytitle("IV Probit Estimate") title("4.4 Takeovers, Unweighted", si(large)) saving(Fig_44, replace) noci  	   
 
  *Table 4
  esttab  M41 M42 M43 /// 
      using "Table_4.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
	  stats ( N_g         N               ll, fmt(%9.0g %9.0g %9.3f %9.1f) ///
	  labels("Countries" "N"  "Log-likelihood")) ///
	  starlevels(* 0.1 ** 0.05) replace nobase noomit label nodepvars ///
	  title("Table 4. Models with Endogenous Hegemony") ///
	  mtitles("Breakdowns" "Coups" "Takeovers") ///
	  order(h legpower enph region demonst pgdp g_1 polity2 effective lewbel)
	  
	  
* Table 5
label var h "Hegemony measure"
replace h = hegemony1
xtprobit break h 
  gen s = e(sample) // Preserve consistent sample
  estimates store M51
replace h = c_pres
xtprobit break h  if s 
 estimates store M52
replace h = c_coal
xtprobit break h  if s 
 estimates store M53
replace h = j_pres
xtprobit break h  if s 
 estimates store M54
replace h = j_party
xtprobit break h  if s 
 estimates store M55
 
 *Table 5
  esttab  M51 M52 M53 M54 M55 /// 
      using "Table_5.rtf", cell(b(star fmt (%9.2f)) p(par))  ///
	  stats ( N_g      N   sigma_u            ll, fmt(%9.0g %9.0g %9.3f %9.1f) ///
	  labels("Countries" "N" "Frailty variance" "Log-likelihood")) ///
	  starlevels(* 0.1 ** 0.05) replace nobase noomit label nodepvars  ///
	  keep(_cons h) ///
	  title("Table 5. Index Components") ///
	  mtitles("Unweighted Index" "Congress: Party" "Congress: Coalition" "Court: President" "Court: Party")
      drop s
